import Mesh = egret3d.Mesh;
import ShadowCast = egret3d.ShadowCast;

class SceneController {
	private static _scene:egret3d.Object3D = new egret3d.Object3D();
	private static _isInitScene:boolean = false;
	protected static _loader:egret3d.MapLoader;

	public constructor() {
	}

	public static initScene():void {
		if ( this._isInitScene ) {
			return;
		}
		this._isInitScene = true;
		//WorldControl.addChild3D( new AxisMesh( 10 ) );
		WorldControl.addChild3D( this._scene );
		this.initCamera();

		this._loader = new egret3d.MapLoader();
		this._loader.addEventListener( egret3d.LoaderEvent3D.LOADER_COMPLETE, this.onMapLoaded, this );
		this._loader.load( 'TestSence' );
	}

	private static initCamera():void {
		rm.CameraController.isOpenFree = true;
		rm.CameraController.xAngle = 20;
		rm.CameraController.yAngle = 0;
		rm.CameraController.distance = 10.5;

	}

	//加载完毕后，所有的mesh创建完毕会添加到loader的container中
	private static onMapLoaded( e:egret3d.LoaderEvent3D ):void {
		this._loader.removeEventListener( egret3d.LoaderEvent3D.LOADER_COMPLETE, this.onMapLoaded, this );
		WorldControl.addChild3D( this._loader.container );
		var obj = this._loader.container;
		rm.CameraController.distance = 1000;
		rm.CameraController.yAngle = 180;
		rm.CameraController.xAngle = 20;
		rm.CameraController.setLookAtObject( obj );
	}
}